package com.rpj.dao;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.rpj.entity.Staticus;

public interface StaticusDao extends JpaRepository<Staticus, Integer>,JpaSpecificationExecutor<Staticus>{
	/**
	 * 统计每天的借书量、还书量
	 */
	@Transactional
	@Modifying
	@Query(value = "insert into staticus(borrowcount,givencount,evenyday) values(?1,?2,now())",nativeQuery = true)
	int insertStautics(int borrow,int given);
	/**
	 * 统计每天借出书的数量
	 */
	@Query(value="select count(*)  from borrow where borrow_date=CURDATE()",nativeQuery = true)
	int countBorrow();
	/**
	 * 统计每天的还书量
	 */
	@Query(value="select count(*)  from borrow where act_return_date=CURDATE()",nativeQuery = true)
	int countGiven();
	
}
